package com.yjj.demo.jpa.user.service;

import com.yjj.demo.jpa.user.dao.UserDao;
import com.yjj.demo.jpa.user.entity.User;
import com.yjj.demo.jpa.user.vo.UserAddVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *
 *
 * @author yangjiajia
 * @time 2021/9/24 23:18
 */
@Service
public class UserService {

    private Logger logger = LoggerFactory.getLogger(UserService.class);

    @Autowired
    private UserDao userDao;

    public long add(UserAddVo userAddVo) {
        User user = new User();
        user.setName(userAddVo.getName());
        user.setAge(userAddVo.getAge());
        user.setCreateTime(System.currentTimeMillis());
        user.setUpdateTime(System.currentTimeMillis());
        userDao.save(user);
        return user.getId();
    }
}
